/*
 * Lab09C.cpp
 *
 *  Created on: Apr 17, 2014
 *      Author: Anthony Varghese
 */


#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

#include <unordered_map>
using std::unordered_map;



int main(){
	cout << "CSIS 237 Lab 9 C - C++ Standard Library unordered_map" << endl;

	/*
	 * This first part sets up a hash table with integer keys and string values
	 */

	typedef unordered_map<int, std::string> intstringtable;
	typedef unordered_map<int, std::string>::value_type iselement;

	intstringtable htable1;

	htable1.insert( iselement(2, "cat") );
	htable1.insert( iselement(3, "dog") );
	htable1.insert( iselement(4, "cow") );
	htable1.insert( iselement(5, "pig") );

	cout << "A table with integer keys and string values:" << endl;
	for (int i=0; i<7; i++)
		cout << "  The value with key " << i << " is: " << htable1[i] << endl;

	cout << endl;


	/*
	 * This next part sets up a hash table with string keys and integer values
	 */

	typedef unordered_map<std::string, int> stringinttable;
	typedef unordered_map<std::string, int>::value_type sielement;

	stringinttable htable2;

	htable2.insert( sielement("cat", 20) );
	htable2.insert( sielement("dog", -1) );
	htable2.insert( sielement("cow", 32) );
	htable2.insert( sielement("pig", 1062) );

	cout << "A table with string keys and integer values:" << endl;

	cout << "  The value with key cat is: " << htable2["cat"] << endl;
	cout << "  The value with key table is: " << htable2["table"] << endl;
	cout << "  The value with key dog is: " << htable2["dog"] << endl;
	cout << "  The value with key cow is: " << htable2["cow"] << endl;
	cout << "  The value with key pig is: " << htable2["pig"] << endl;
	cout << "  The value with key river is: " << htable2["river"] << endl;

	cout << "done!" << endl;
}

